package com.example.controller;


import com.example.entity.PsInspectiontaskDetail;
import com.example.entity.PsInspectiontaskMain;
import com.example.service.PsInspectiontaskDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 */

@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@Slf4j
public class PsSystemconfigControllers {
    @Autowired
    private PsInspectiontaskDetailService psInspectiontaskDetailService;


    @PostMapping("/psInspectiontask")
    private List<PsInspectiontaskDetail> Chaxunquanbumian(){
        List<PsInspectiontaskDetail> psInspectiontaskDetails=psInspectiontaskDetailService.list();
        return psInspectiontaskDetails;
    }

    @PostMapping("/psInspectiontask2")
    private List<PsInspectiontaskDetail> Chaxunquanbumian2(String inspectionTaskCode, String inspectionTaskName, Integer xiala){
        List<PsInspectiontaskDetail> psInspectiontaskDetails=null;
        if(inspectionTaskCode==null ||"".equals(inspectionTaskCode) || inspectionTaskName==null ||"".equals(inspectionTaskName)  || xiala==null || "".equals(xiala)){
            psInspectiontaskDetails=psInspectiontaskDetailService.list();
        }else if(!inspectionTaskCode.equals("") && inspectionTaskName.equals("")){
            psInspectiontaskDetails=psInspectiontaskDetailService.chaxun2(inspectionTaskCode,inspectionTaskName);
        }else if(!inspectionTaskCode.equals("") || inspectionTaskName.equals("")){
            psInspectiontaskDetails=psInspectiontaskDetailService.chaxun2(inspectionTaskCode,inspectionTaskName);
        }else if(!xiala.equals("")){
            psInspectiontaskDetails=psInspectiontaskDetailService.pslist(xiala);
        }
        return psInspectiontaskDetails;
    }

    @GetMapping("/prinSelect")
    private List<PsInspectiontaskMain> chakan(Integer id){
        List<PsInspectiontaskMain> psInspectiontaskDetails=psInspectiontaskDetailService.chaxun(id);
        return psInspectiontaskDetails;
    }



}
